package com.lyy.photovoltaic.controller;

import com.lyy.photovoltaic.common.vo.ResultVO;
import com.lyy.photovoltaic.service.UserCartService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@CrossOrigin
@RequestMapping("/userCart")
@Api(value = "用户购物车接口", tags = "购物车管理")
public class UserCartController {
    @Autowired
    UserCartService userCartService;
    @PostMapping(value = "/{uid}")
    @ApiImplicitParam(dataType = "string", name = "uid", value = "用户创建购物车", required = true)
    public ResultVO addUserCart(@PathVariable("uid") String userId) {
        ResultVO resultVO = userCartService.addUserCart(userId);
        return resultVO;
    }
    @GetMapping(value = "/{uid}")
    @ApiImplicitParam(dataType = "string", name = "uid", value = "根据用户id查询相关购物车id", required = true)
    public ResultVO getUserCartId(@PathVariable("uid") String userId) {
        ResultVO resultVO = userCartService.getUserCartId(userId);
        return resultVO;
    }



}
